package measurement.main;

import java.sql.Timestamp;
import java.util.concurrent.ExecutorService;

import org.apache.log4j.Logger;

import wiiusej.Wiimote;
import wiiusej.apptest.statistics.AccelerationPaquetList;
import wiiusej.apptest.statistics.PacketWraped;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteBasicListener;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;

public class WiimoteMeasurementListener implements WiimoteBasicListener{

	//Concurrent Main Class
	protected static ExecutorService exe;
	
	//Wiimote object representation
	protected Wiimote wiimote;
	
	//Measurement length in packets
	protected Long measurementLength;
	
	//Datastructure where the acceleration data is stored
	protected PacketWraped myPackets;
	protected AccelerationPaquetList accPacketList;
	
	protected long randomID;
	
	public WiimoteMeasurementListener(ExecutorService exe, Wiimote aux, String measurementLength){
		this.exe = exe;
		this.wiimote = aux;
		this.measurementLength = Long.parseLong(measurementLength);		
		this.accPacketList = new AccelerationPaquetList(wiimote.getId());
		this.myPackets = new PacketWraped(accPacketList);		
	}
	
	
	protected void activateMotionSensing() {
		wiimote.activateMotionSensing();		
	}
	
	protected void removeListener(){
		wiimote.removeWiiMoteEventListeners(this);
	}
	
	/***********************************************************
	//WIIMOTE LISTENER INTERFACE 
	************************************************************/


	@Override
	public void onButtonsEvent(WiimoteButtonsEvent e) {				
	}

	@Override
	public void onDisconnectionEvent(DisconnectionEvent e) {
				
	}

	public void onMotionSensingEvent(MotionSensingEvent e, long packetRefNumber) {				
		
	}

	@Override
	public void onStatusEvent(StatusEvent e) {
				
	}

	public void registerListeners() {
				
	}
	
	public Wiimote getWiimote(){
		return this.wiimote;		
	}


	public synchronized PacketWraped getMyPackets() {
		return myPackets;
	}


	public synchronized void setMyPackets(PacketWraped myPackets) {
		this.myPackets = myPackets;
	}


	@Override
	public void onMotionSensingEvent(MotionSensingEvent e,
			long packetRefNumber, Timestamp timestamp) {
		
		
	}
	
	

}
